<#include "../inc/header.ftl" />
<#import "/META-INF/spring.ftl" as spring />
<#import "/META-INF/mspring.ftl" as mspring />
	<script type="text/javascript" src="${base}/script/kindeditor/kindeditor.js" charset="utf-8"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			mlog.editor.ins.createPostEditor = mlog.editor.init({
				type : "kindeditor",
				model : "all",
				id : "toDoComent"
			});
			mlog.editor.ins.createPostSummaryEditor = mlog.editor.init({
				type : "kindeditor",
				model : "simple",
				id : "summary"
			});
			
			$("#user_select").multiselect({
				header:false,
				selectedList: 4,
				click: function(event, ui){
					var values = $("#user").val();
					if(ui.checked){
						values += ui.value + ',';
					}
					else{
						values = values.replace(ui.value + ',', '');
					}
					$("#user").val(values);
				}
			});
		});
	</script>
	<div class="ui-layout-center">
		<div class="tab">
			<ul>
			    <li><a href="${base}/admin/todo/list">列表</a></li>
			    <li><a href="javascript:void(0);" class="here">增加</a></li>
			    <li><a href="javascript:void(0);">修改</a></li>
			</ul>
		</div>
		<div class="tab-container">
			<div id="error" class="message error" style="display:none;"></div>
			<form id="todoForm" name="todoForm" action="${base}/admin/todo/doCreate" method="POST">
				<@mspring.show_errors />
				<table class="formtable" style="width:100%;">
					<tr>
						<td>
							<table class="formtable" style="width:100%;">
								<tr>
									<td class="fieldlabel">课题内容:
									</td>
									<td>
										<@spring.formTextarea path="toDo.toDoComent" attributes='style="height:200px;width:100%;"' />
									</td>
								</tr>
								<tr>
									<td class="fieldlabel" width="20%">担当者:
									</td>
									<td>
										<select id="user_select" multiple="multiple">
											<#if (user?exists && user?size > 0)>
												<#list user as u>
													<option value="${u.getUSER_ID()}">${u.getREAL_NAME()}</option>
												</#list>
											</#if>
										</select>
										<input type="hidden" id="bearuser" name="bearuser" />
									</td>
								</tr>
								<tr>
									<td class="fieldlabel" width="20%">优先度:
									</td>
									<td>
										<select id="level_select">
											<#if (codeBook?exists && codeBook?size > 0)>
												<#list codeBook as cBook>
													<option value="${cBook.code}">${cBook.name}</option>
												</#list>
											</#if>
										</select>
										<input type="hidden" id="level" name="level" />
									</td>
								</tr>
								<tr>
									<td class="fieldlabel" width="20%">希望解决日期:
									</td>
									<td>
									</td>
								</tr>
								<tr>
									<td class="fieldlabel" width="20%">是否公开:
									</td>
									<td style="font-size:12px;">
										<@spring.formRadioButtons path="toDo.commentStatus" options=commentStatus defaultValue="open" separator="&nbsp;" />
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr>
						<td colspan="4" style="text-align:center;">
							<input type="button" class="btn" value=" 确定 " onclick="publish();" />
							<input type="button" class="btn" value=" 取消 " onclick="draft();" />
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	<script type="text/javascript">
		//发布
		function publish(){
			$("#status").val("publish");
			if($("#todoForm").valid()){
				mlog.form.submitForm("todoForm");
			}
		}
		//存为草稿
		function draft(){
			$("#status").val("draft");
			mlog.form.submitForm("todoForm");
		}
		
		$(document).ready(function(){
			//斑马线
			var tables=document.getElementsByTagName("table");
			var b=false;
			for (var j = 0; j < tables.length; j++){
				var cells = tables[j].getElementsByTagName("tr");
				//cells[0].className="color3";
				b=false;
				for (var i = 0; i < cells.length; i++){
					if(b){
						cells[i].className="color2";
						b=false;
					}
					else{
						cells[i].className="color3";
						b=true;
					};
				};
			}
			
			mlog.form.validate({
				selector : "#todoForm",
				errorLabelContainer : "#error",
				wrapper: 'li',
				onfocusout : false,
				onkeyup : false,
				onclick : false,
				success : function(){
					mlog.utils.scrollTop();
				}
			});
			
		});
	</script>
<#include "../inc/footer.ftl" />